<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>模态框</title>
    <link href="bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <script src="jquery-3.2.1.js"></script>
    <script src="bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
</head>
<body>
<h2 id="title1">创建模态框</h2>
<button class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">开始演示模态框</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">渡情</h4>

            </div>
            <div class="modal-body">西湖的水,我的泪</div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary">提交更改</button>
            </div>
        </div>
    </div>
</div>

<script>
//        $(function () {
//            $('#myModal').modal('toggle')
//        });
        $('#myModal').on("show.bs.modal",function () {
            $('#title1').css("color","cyan");
        });

        $('#myModal').on("hide.bs.modal",function () {
            $('#title1').css("color","blue");
        });

        $('#myModal').on("shown.bs.modal",function () {
            $('#title1').css("color","yellow");
        });
        $('#myModal').on("hidden.bs.modal",function () {
            $('#title1').css("color","red");
        });
</script>

</body>
</html>